package com.lau.dicttranslator.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lau.dicttranslator.entity.DictData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 字典数据Mapper
 */
@Mapper
public interface DictDataMapper extends BaseMapper<DictData> {
    
    /**
     * 根据字典类型和键值查询字典标签
     */
    @Select("SELECT dict_label FROM dict_data WHERE dict_type = #{dictType} AND dict_key = #{dictKey} AND status = 1")
    String findDictLabelByTypeAndKey(@Param("dictType") String dictType, @Param("dictKey") String dictKey);
    
    /**
     * 根据字典类型查询所有启用的字典数据
     */
    @Select("SELECT * FROM dict_data WHERE dict_type = #{dictType} AND status = 1 ORDER BY sort_order")
    List<DictData> findByDictTypeAndStatusOrderBySortOrder(@Param("dictType") String dictType);
} 